package app

import (
	"database/sql"
	"fmt"

	_ "github.com/go-sql-driver/mysql"
)

type mysqlCreator struct {
	host     string
	port     string
	user     string
	password string
	database string
}

var MysqlCreator MysqlCreatorInterface = &mysqlCreator{}

func (this mysqlCreator) make() *sql.DB {
	this.host = ""
	this.port = ""
	this.user = ""
	this.password = ""
	this.database = ""
	fmt.Println("init mysql")
	DB, err := sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s:%s)/%s", this.user, this.password, this.host, this.port, this.database))
	if err != nil {
		fmt.Println(err)
		panic("数据库连接失败")
	}
	return DB
}
